//
// Created by Jisam on 2024/6/12.
//
#include "iostream"
#include "cstring"
using namespace std;
#define int long long
#define endl "\n"
#define x first
#define y second
#define INF 0x3f3f3f3f
#define PII pair<int,int>
const int N = 1e5+10;
const int mod = 1e9+7;
int b[10][10];
bool vis[10];
int n,k;

int ans;
void dfs(int x,int y){
    // judge
    if(y > k){
        ans ++;
        return;
    }

    for(int i = x; i <= n; i ++){
        for(int j = 1; j <= n ; j ++){
            if(!vis[j] && b[i][j] == 1){
                vis[j] = true;
                dfs(i + 1 , y + 1);
                vis[j] = false;
            }
        }
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    while(cin >> n >> k){
        if(n ==  -1 ||  k == -1) break;
        char x;
        memset(b,0, sizeof b);
        memset(vis,0, sizeof vis);

        for(int i = 1 ; i <= n ; i ++){
            for(int j  = 1 ; j  <= n ; j ++){
                cin >> x;
                if(x == '.') {
                    b[i][j] = 0;continue;
                }
                if (x == '#'){
                    b[i][j] = 1;continue;
                }
                cout << x << " : " << b[i][j];
            }

        }
        ans = 0;

        dfs(1,1);
        cout << ans << endl;

    }
    return 0;
}